﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Post.aspx.cs" Inherits="DjBlog.Admin.Post" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>后台文章</title>
    <style type="text/css">
    * {margin: 0;padding: 0;}
    .cat img { border:0px; margin-left:20px;}
    body { font-family: Arial, Helvetica, sans-serif,Georgia, "Times New Roman", serif;font-size: 72.5%;background:url(../image/body_bg.png) repeat-x #F2F2F2;color: #444;}	.content { margin:20px auto; width:960px;}	.content div{ margin-bottom:10px;}	.cat {width:700px; }    textarea {display: block; width:710px;}
    .checkbox {margin:0 2px 5px 10px;}
    </style>
</head>
<body>
    <div class="content">
        <form runat="server" id="form">
            <div>标题：<input type="text" name="title"  style="width:150px;" value="<%=mpost.Title%>" /></div>
            <div>描述：<input type="text" name="des"  style="width:250px;" value="<%=mpost.Excerpt%>" /></div>
            <div class="cat">分类：
            <% if (DjBll.Term.TermCateDic != null)
               {
                   foreach (System.Collections.Generic.KeyValuePair<int, DjModel.TermInfo> kv in DjBll.Term.TermCateDic)
                   { %>
                   <input type="checkbox" class="checkbox" name="cat" value="<%=kv.Key %>" /><%=kv.Value.TermName %>
            <%}
               } %>
               <input type="text" size="8" id="addcattxt"/><input id="addcatbtn" type="button" value="" style="background: #F2F2F2 url(/image/tagnew.png) no-repeat; border:0px; width:18px; height:20px;"; />
            </div>
            <div class="cat">标签：
            <% if (DjBll.Term.TermTagDic != null)
               {
                   foreach (System.Collections.Generic.KeyValuePair<int, DjModel.TermInfo> kv in DjBll.Term.TermTagDic)
                   { %>
                   <input type="checkbox" class="checkbox" name="tag" value="<%=kv.Key %>" /><%=kv.Value.TermName %>
            <%}
               } %>
               <input type="text" id="addtagtxt" size="8"/><input id="addtagbtn" type="button" value="" style="background: #F2F2F2 url(/image/tagnew.png) no-repeat; border:0px; width:18px; height:20px;"; />
            </div>
            <div>
                <textarea id="content" name="content" cols="22" rows="22"><%=mpost.Content%></textarea>
            </div>
            <div><input type="hidden" name="postid" value="<%=mpost.ID %>" /><input type="submit" value="submit" /></div>
        </form>
    </div>
    <script type="text/javascript" src="/js/kindeditor/kindeditor.js"></script>
    <script type="text/javascript" src="/js/jquery-1.5.js"></script>
	<script type="text/javascript">
	    var djblog = djblog || {};
	    djblog.admin = {
	        addcatbtn: $("#addcatbtn"),
	        addcattxt: $("#addcattxt"),
	        addtagbtn: $("#addtagbtn"),
	        addtagtxt: $("#addtagtxt"),
	        ajaxurl: '/ashx/post.ashx?act=addterm',
	        init: function() {
	            this.addcatbtn.click(function() { djblog.admin.ajaxsub(djblog.admin.addcattxt, 0); });
	            this.addtagbtn.click(function() { djblog.admin.ajaxsub(djblog.admin.addtagtxt, 1); });
	        },
	        ajaxsub: function(el, type) {
	            $.ajax({
	                type: "POST",
	                url: djblog.admin.ajaxurl,
	                data: { value: el.val(), type: type },
	                dataType: 'json',
	                success: function(d) {
	                    djblog.admin.callback(d, el, type);
	                }
	            });
	        },
	        callback: function(d, el, type) {
	            var html = "";
	            if (d.ret > 0) {
	                html = '<input type="checkbox" class="checkbox" name="' + (type ? 'tag' : 'cat') + '" value="' + d.ret + '" />';
	                el.before(html);
	                el.before(d.name);
	                el.val("");
	            }
	            else {
	                alert("错误代码"+d.ret);
	            }

	        }
	    };
	    $(function() {
	        KE.show({
	            id: 'content',
	            cssPath: './index.css'
	        });
	        djblog.admin.init();
	    });
	</script>
</body>
</html>
